#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(x) (ll)x.size()
#define lb(x) (x&-x)
#define rep(i,x,y) for(ll i=(x);i<=(y);i++)
#define per(i,x,y) for(ll i=(x);i>=(y);i--)
using namespace std;
using ll=long long;
using ull=unsigned long long;
using db=double;
using pll=pair<ll,ll>;
const ll N=400005;
const ll inf=0x3f3f3f3f3f3f3f3f;
ll a[N],b[N];
int main(){
	ios::sync_with_stdio(0),cin.tie(0);
	freopen("kte.in","r",stdin);
	freopen("kte.out","w",stdout);
	ll t;
	cin>>t;
	set<ll> s;
	while(t--){
		ll x;
		cin>>x;
		if(s.find(x)==s.end()){
			s.insert(x);
		}
		else{
			s.erase(x);
		}
		ll len=0;
		for(auto it=s.begin();it!=s.end();it++){
			len++;
			a[len]=a[len-1]+*it;
		}
		len=0;
		for(auto it=s.rbegin();it!=s.rend();it++){
			len++;
			b[len]=b[len-1]+*it;
		}
		ll R=-inf,ans=0;
		rep(i,1,len){
			ll l=a[i],r=b[i]-1;
			if(l>R){
				ans+=r-l+1;
			}
			else{
				ans+=r-R;
			}
			R=r;
		}
		cout<<ans<<'\n';
	}
	return 0;
}
